<template>
  <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/confirmedPatient' }"
      >首页</el-breadcrumb-item
    >
    <el-breadcrumb-item>新建密切接触者</el-breadcrumb-item>
  </el-breadcrumb>
  <el-card label="密切接触者信息">
    <el-form :label-position="labelPosition" label-width="80px">
      <el-form-item label="姓名">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="身份证号">
        <el-input v-model="form.idCard"></el-input>
      </el-form-item>
        <el-form-item label="性别">
          <el-select v-model="form.gender" placeholder="请选择">
          <!-- :label="item.label" -->
            <el-option
              v-for="item in options"
              :key="item.value"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
      <el-form-item label="电话号码">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>

      <div class="block">
        <el-form-item label="隔离时间">
          <el-date-picker
            v-model="form.time"
            type="datetime"
            placeholder="选择日期时间"
            align="right"
            :picker-options="pickerOptions"
          >
          </el-date-picker>
        </el-form-item>
      </div>
      <el-form-item label="接触源">
        <el-input v-model="form.resource"></el-input>
      </el-form-item>
      <el-form-item label="症状">
        <el-input v-model="form.desc"></el-input>
      </el-form-item>
      <el-form-item label="隔离地点">
        <el-input v-model="form.address"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>
    
    <script>
import { addTouchApi } from "../api/index1.js";
import { ElMessage } from "element-plus";
export default {
  data() {
    return {
            options: [
        {
          value: "男",
          // label: "男",
        },
        {
          value: "女",
          // label: "女",
        },
      ],
      labelPosition: "left",
      form: {
        name: "",
        idCard: "",
        phone: "",
        time: "",
        resource: "",
        desc: "",
        address: "",
        gender:''
      },
    };
  },
  methods: {
    onSubmit() {
      // console.log('submit!');
      addTouchApi(this.form).then((res) => {
        console.log(res);
        this.form = {};
        // 2.提示用户添加成功
        if (res.code == 20000) {
          ElMessage({
            message: "添加成功",
            type: "success",
          });
        }
        //   this.$router.back()
        this.$router.push(name="touch");
      });
    },
  },
};
</script>
    
    <style lang="less" scoped>
.el-card {
  margin-top: 20px;
}
.el-form {
  width: 800px;
}
.el-input {
  width: 220px;
}
</style>